<template>
	<view>
		<nav-bar></nav-bar>
		<view style="padding: 0 30px;">
			<view style="font-size: 20px;font-weight: 600;color: #000000;line-height: 28px;letter-spacing: 1px;">帮我选址</view>
			<view style="margin-top:18px;font-size: 12px;font-weight: 400;color: #A1A2A4;line-height: 17px;">
				请输入以下信息，选址顾问会根据您提供的信息，为 您精准推荐合适您的园区。
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					你所属的公司名称
				</view>
				<view><u--input placeholder="请输入公司名称" border="surround" v-model="temp.gongsiname"></u--input></view>
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					你公司/项目核心业务
				</view>
				<view><u--input placeholder="请输入核心业务" border="surround" v-model="temp.hexinyewu"></u--input></view>
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					你所需要的载体类型
				</view>
				<view style="margin-top:8px;">
					<u-checkbox-group v-model="temp.zaitileixing" placement="column">
						<view
							v-for="(item, index) in needList"
							:class="[index == 0 ? 'borderTop' : '']"
							style="border-left: solid 1px #DCDFE6;border-right: solid 1px #DCDFE6;border-bottom: solid 1px #DCDFE6;padding:14px 24px 9px 24px;"
						>
							<u-checkbox :customStyle="{ marginBottom: '8px' }" :key="index" :label="item.name" :name="item.name"></u-checkbox>
						</view>
					</u-checkbox-group>
				</view>
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					意向城市
				</view>
				<view><u--input placeholder="请输入意向的城市" border="surround" v-model="temp.yixiangchengshi"></u--input></view>
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					该项目预计投资(万元)
				</view>
				<view><u--input placeholder="请输入数字" border="surround" v-model="temp.yujitouzi"></u--input></view>
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					期望获得的支持是
				</view>
				<view style="margin-top:8px;">
					<u-checkbox-group v-model="temp.qiwanghuodezhichi" placement="column">
						<view
							v-for="(item, index) in supportList"
							:class="[index == 0 ? 'borderTop' : '']"
							style="border-left: solid 1px #DCDFE6;border-right: solid 1px #DCDFE6;border-bottom: solid 1px #DCDFE6;padding:14px 24px 9px 24px;"
						>
							<u-checkbox :customStyle="{ marginBottom: '8px' }" :key="index" :label="item.name" :name="item.name"></u-checkbox>
						</view>
					</u-checkbox-group>
				</view>
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					你的联系方式
				</view>
				<view style="margin-top:12px;"><u--input placeholder="请输入手机号码" border="surround" v-model="temp.lianxifangshi"></u--input></view>
				<view class="flex flex-row" style="margin-top:16px;">
					<!-- <view class="flex-1"><u--input placeholder="请输入内容" border="surround" v-model="temp.value"></u--input></view> -->
					<!-- <view style="width:100px;">
						<u-toast ref="uToast"></u-toast>
						<u-code ></u-code>
						<span @click="sendSignUpcode"  v-show="show" class="getcode">获取验证码</span>
						           <span class="register-msg-btn" v-show="!show">{{count}} s</span>
					</view> -->
				</view>
			</view>
			<view style="margin-top:13px;font-size: 12px;font-weight: 400;color: #B4B8C0;">选址顾问会在收到需求后24小时内与您取得联系，并做初步的推荐。</view>
			<view style="margin-top:23px;"><u-button type="primary" color="#FE7743" text="确定" @click="addContact"></u-button></view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			temp: {
				gongsiname: '',
				hexinyewu: '',
				zaitileixing: '',
				yixiangchengshi: '',
				yujitouzi: '',
				qiwanghuodezhichi: '',
				lianxifangshi: '',
				// phonenumber:''
				mobile: '',
				value: ''
			},
			// tips: '60',
			seconds: 10,
			show: true,
			timer: null,
			count: '',
			// mobile:uni.getStorageSync('mobile'),
			supportList: [
				{
					name: '市场支持',
					disabled: false
				},
				{
					name: '政策支持',
					disabled: false
				},
				{
					name: '土地/厂房支持',
					disabled: false
				},
				{
					name: '税收减免',
					disabled: false
				},
				{
					name: '研发补贴',
					disabled: false
				},
				{
					name: '创新奖励',
					disabled: false
				},
				{
					name: '人才奖励',
					disabled: false
				},
				{
					name: '其他',
					disabled: false
				}
			],
			needList: [
				{
					name: '土地',
					disabled: false
				},
				{
					name: '厂房',
					disabled: false
				},
				{
					name: '仓库',
					disabled: false
				},
				{
					name: '写字楼',
					disabled: false
				},
				{
					name: '其他',
					disabled: false
				}
			]
		};
	},
	methods: {
		// codeChange(text) {
		// 	this.tips = text;
		// },
		// getCode() {
		// 	let that = this;
		// 	this.$apiCall.request(
		// 		'post',
		// 		'/sendcode',
		// 		{

		// 			phonenumber: that.temp.lianxifangshi
		// 		},
		// 		{
		// 			sucCb(data) {
		// 				uni.$u.toast(data.data.msg);
		// 				if (this.$refs.uCode.canGetCode) {
		// 					// 模拟向后端请求验证码
		// 					uni.showLoading({
		// 						title: '正在获取验证码'
		// 					});
		// 					setTimeout(() => {
		// 						uni.hideLoading();
		// 						// 这里此提示会被this.start()方法中的提示覆盖
		// 						uni.$u.toast('验证码已发送');
		// 						// 通知验证码组件内部开始倒计时
		// 						this.$refs.uCode.start();
		// 						this.tips = this.tips-1
		// 					}, 60000);
		// 				}
		// 			}
		// 		}
		// 	);
		// },
		sendSignUpcode() {
			let that = this;

			this.$apiCall.request(
				'post',
				`/sendcode?phonenumber=${that.temp.lianxifangshi}`,
				{},
				{
					sucCb(data) {
						if (data.code === 0) {
							// this.resetTemp()
							uni.showToast({
								title: '发送成功',
								icon: 'none',
								duration: 2000
							});
							that.getCode();
						} else {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 2000
							});
						}
					}
				}
			);
		},
		getCode() {
			this.show = false;
			const TIME_COUNT = 60;
			if (!this.timer) {
				this.count = TIME_COUNT;
				this.show = false;
				this.timer = setInterval(() => {
					if (this.count > 0 && this.count <= TIME_COUNT) {
						this.count--;
					} else {
						this.show = true;
						clearInterval(this.timer);
						this.timer = null;
					}
					title: '已提交成功';
				}, 2000);
			}
		},

		addContact() {
			if (this.temp.gongsiname == '') {
				return uni.showToast({
					title: '公司名称不能为空',
					icon: 'none',
					duration: 2000
				});
			}
			if (this.temp.hexinyewu == '') {
				return uni.showToast({
					title: '核心业务不能为空',
					icon: 'none',
					duration: 2000
				});
			}
			if (this.temp.zaitileixing == '') {
				return uni.showToast({
					title: '请勾选载体类型',
					icon: 'none',
					duration: 2000
				});
			}
			if (this.temp.yixiangchengshi == '') {
				return uni.showToast({
					title: '意向城市不能为空',
					icon: 'none',
					duration: 2000
				});
			}
			if (this.temp.zaitileixing == '') {
				return uni.showToast({
					title: '请勾选载体类型',
					icon: 'none',
					duration: 2000
				});
			}
			if (this.temp.yujitouzi == '') {
				return uni.showToast({
					title: '预计投资不能为空',
					icon: 'none',
					duration: 2000
				});
			}
			if (this.temp.qiwanghuodezhichi == '') {
				return uni.showToast({
					title: '请勾选期望获得的支持',
					icon: 'none',
					duration: 2000
				});
			}if (this.temp.lianxifangshi == '') {
				return uni.showToast({
					title: '联式方式不能为空',
					icon: 'none',
					duration: 2000
				});
			}
			let that = this;
			this.$apiCall.request(
				'post',
				'/woyaoxuanzhi/add',
				{
					company: that.temp.gongsiname,
					business: that.temp.hexinyewu,
					carrier: that.temp.zaitileixing.join(),
					city: that.temp.yixiangchengshi,
					investment: that.temp.yujitouzi,
					expectations: that.temp.qiwanghuodezhichi.join(),
					mobile: that.temp.lianxifangshi
				},
				{
					sucCb(data) {
						uni.$u.toast(data.data.msg);
					}
				},
				setTimeout(() => {
					uni.navigateBack();
				}, 1000)
			);
		},
		end() {
			uni.$u.toast('倒计时结束');
		},
		start() {
			uni.$u.toast('倒计时开始');
		}
	}
};
</script>

<style lang="scss">
.borderTop {
	border-top: solid 1px #dcdfe6;
}
</style>
